Fix most external/wpt/longtask-timing tests This CL fixes all external/wpt/longtask-timing tests except for those with cross-origin iframes, which may pass or timeout. It also fixes some nits like using 'const' instead of 'var' and single quotes in js. Finally, it also removes a folder containing duplicate tests: http/tests/performance-timing/longtask Bug: chromium:754819 Change-Id: Ib1931ba47522d9d3c64f519d781d080ba2b62b91 Reviewed-on: https://chromium-review.googlesource.com/614095 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: Kentaro Hara <haraken@chromium.org> WPT-Export-Revision: 069aade865e739259c5306a1bd9a34d4b4b98b1c
diff --git a/longtask-timing/longtask-in-childiframe.html b/longtask-timing/longtask-in-childiframe.html index 53c27c3..46aca30 100644 --- a/longtask-timing/longtask-in-childiframe.html +++ b/longtask-timing/longtask-in-childiframe.html
@@ -9,40 +9,48 @@ <h1>Long Task in Nested Child Iframe</h1> <div id="log"></div> <script> + const initialTime = performance.now(); async_test(function (t) { - var observer = new PerformanceObserver( + const observer = new PerformanceObserver( t.step_func(function (entryList) { - var entries = entryList.getEntries(); + const entries = entryList.getEntries(); assert_equals(entries.length, 1, - "Exactly one entry is expected."); - var longtask = entries[0]; - assert_equals(longtask.entryType, "longtask"); - assert_equals(longtask.name, "same-origin-descendant"); + 'Exactly one entry is expected.'); + const longtask = entries[0]; + assert_equals(longtask.entryType, 'longtask'); + if (longtask.name == 'self' || + longtask.name == 'multiple-contexts' || + longtask.name == 'unknown') + return; + + assert_equals(longtask.name, 'same-origin-descendant'); assert_greater_than(longtask.duration, 50); - assert_equals(longtask.startTime, Math.floor(longtask.startTime), - "startTime expected to have 1 millisecond granularity"); + assert_greater_than_equal(longtask.startTime, initialTime); + const currentTime = performance.now(); + assert_less_than_equal(longtask.startTime, currentTime); // Assert the TaskAttributionTiming entry in attribution. assert_equals(longtask.attribution.length, 1, - "Exactly one attribution entry is expected"); - var attribution = longtask.attribution[0]; - assert_equals(attribution.entryType, "taskattribution"); - assert_equals(attribution.name, "frame"); + 'Exactly one attribution entry is expected'); + const attribution = longtask.attribution[0]; + assert_equals(attribution.entryType, 'taskattribution'); + assert_equals(attribution.name, 'script'); assert_equals(attribution.duration, 0); assert_equals(attribution.startTime, 0); - assert_equals(attribution.frameId, "child-iframe-id"); - assert_equals(attribution.frameName, "child-iframe-name"); - assert_equals(attribution.frameSrc, "resources/subframe-with-longtask.html"); + assert_equals(attribution.containerId, 'child-iframe-id'); + assert_equals(attribution.containerName, 'child-iframe-name'); + assert_equals(attribution.containerSrc, 'resources/subframe-with-longtask.html'); observer.disconnect(); t.done(); }) ); - observer.observe({entryTypes: ["longtask"]}); - -}, "Performance longtask entries in child iframe are observable in parent"); - + observer.observe({entryTypes: ['longtask']}); + const iframe = document.createElement('iframe'); + iframe.id = 'child-iframe-id'; + iframe.name = 'child-iframe-name'; + document.body.appendChild(iframe); + iframe.src = 'resources/subframe-with-longtask.html'; +}, 'Performance longtask entries in child iframe are observable in parent.'); </script> -<iframe src="resources/subframe-with-longtask.html" id="child-iframe-id" name="child-iframe-name"></iframe> - -</body> \ No newline at end of file +</body>